<template>
	<div class="fileStyle">
		<el-upload class="upload-demo" 	
		action="/api/oss/uploadOSS"
		:on-preview="handlePreview"
		:disabled="true"
		:file-list="fileList">
		</el-upload>
	</div>
</template>

<script>
	import envCfg from '../../assets/js/env.js'
	export default {
		data() {
			return {
				fileList: [],
				fileListss:[],
				fileData:{}
			}
		},
		props:{
			pfileList:{
				type:Array,
				default(){
					return []
				}
			}
		},
		watch:{
			pfileList:function(val){
				this.fileListss = val	
				if(this.fileListss.length!==0){
					this.fileListss.forEach(item=>{
						this.fileList.push({
							name:item.originalFileName,
							response:{data:[item]}
						})
					})
				}
			}
		},
		methods: {
			handlePreview(file) {
				window.open('/api/oss/downloadOSS?fileName='+file.response.data[0].fileName)
			}
		},
		mounted(){
			if(this.pfileList.length!==0){
				this.pfileList.forEach(item=>{
					this.fileList.push({
						name:item.originalFileName,
						externalLink:item.externalLink,
						response:{data:[item]}
					})
				})
			}
			
		}
	}
	
</script>

<style lang="scss" scoped>
	.fileStyle{
		// height: 40px;
		position: relative;
		bottom: 42px;
	}
	.el-upload-list{
		width: 80%;
	}
	.el-upload__tip{
		color: #999999;
		font-size: 12px;
		margin-left: 12px;
	}
	.upload-demo{
		margin-bottom: -40px;
	}
	.fileStyle{
		::v-deep .el-upload-list{
		width: 425px !important;
	}
	}
	
</style>
